package com.balabala.gym_system.controller.admin;


import com.balabala.goods.pojo.vo.BookCourseDto;
import com.balabala.gym_enum.ResultEnum;
import com.balabala.gym_system.pojo.dto.ReservationInfoQueryDto;
import com.balabala.gym_system.pojo.dto.ReservationListDto;
import com.balabala.gym_system.pojo.entity.ReservationInfo;
import com.balabala.gym_system.pojo.vo.CourseInfoVo;
import com.balabala.gym_system.pojo.vo.ReservationInfoVo;
import com.balabala.gym_system.pojo.vo.ReservationVo;
import com.balabala.gym_system.service.ReservationInfoService;
import com.balabala.gym_system.service.ReservationListService;
import com.balabala.result.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "预约记录接口")
@RequestMapping("/admin/ReservationInfo")
@CrossOrigin
public class ReservationInfoController {

    @Autowired
    private ReservationInfoService reservationInfoService;

    //根据条件列表查询
    @PostMapping("/findList")
    @ApiOperation(value = "预约记录列表")
    public Result findList(@RequestParam Long bookId){


        List<ReservationInfoVo> list = reservationInfoService.findListByBookId(bookId);


        //远程调用教练，场馆，场地
        return Result.ok(list);

    }

    //添加预约记录
    @PostMapping("/addReservationInfo")
    @ApiOperation(value = "添加预约记录")
    public Result addReservationInfo(@RequestBody ReservationInfo reservationInfo){

        reservationInfoService.addReservationInfo(reservationInfo);

        return Result.ok();
    }

    //根据id删除预约记录
    @GetMapping("/deleteById")
    @ApiOperation(value = "删除预约记录")
    public Result deleteById(@RequestParam Long id){

        reservationInfoService.deleteById(id);

        return Result.ok();
    }

    //根据id签到
    @GetMapping("/updateStatusById")
    @ApiOperation(value = "根据预约记录id签到")
    public Result updateStatusById(@RequestParam Long id) {

        reservationInfoService.updateStatusById(id);

        return Result.ok(ResultEnum.GENERALLY_SUCCESS);

    }

    //根据排课id查询排课详情信息
    @GetMapping("/findByScheduleId")
    @ApiOperation(value = "根据排课id查询排课详情信息")
    public Result  findByScheduleId(Long scheduleId){

        CourseInfoVo byScheduleId = reservationInfoService.findByScheduleId(scheduleId);

        return Result.ok(byScheduleId);

    }

}
